package com.mf.all.task;

import com.mf.all.service.ITaskNotificationService;
import com.mf.all.service.ITaskService;
import jakarta.annotation.Resource;
import lombok.extern.slf4j.Slf4j;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;

import java.time.LocalDate;

/**
 * @Author: lmf
 * @Create: 2025/3/25 21:14
 * @module 监听任务是否需要通知
 */
@Component
@Slf4j
public class MonitorTaskInForm {

    @Resource
    private ITaskNotificationService taskNotificationService;

    @Resource
    private ITaskService taskService;

    //    @XxlJob("monitorTaskInForm")
    @Scheduled(cron = "0 * * * * ?")
    public void monitorTaskInForm() {
        log.info("开始通知");
        taskNotificationService.sendNotification();
        log.info("通知结束");
    }

    /**
     * 更新当天的任务通知
     */
//    @XxlJob("updateTaskDayNotification")
    @Scheduled(cron = "2 0 0 * * ?")
    public void updateTaskDayNotification() {
        taskService.updateTaskDayNotification(LocalDate.now());
    }
}
